package com.homedo.async.mysql.support.mapper.select;

import com.homedo.async.common.dto.Pagination;
import com.homedo.async.mysql.support.mapper.MapperI;
import io.vertx.sqlclient.SqlConnection;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;

/**
 * @author jgshun
 * @date 2020/3/17 10:38 AM
 */
public interface SelectPaginationMapperI<T, ID> extends MapperI<T, ID> {

    Flux<T> findAll(Pagination<T> pagination);

    Flux<T> findByRecordSelective(T entity, Pagination<T> pagination);

    Flux<T> findByRecordSelective(Publisher<? extends T> entityStream, Pagination<T> pagination);

    Flux<T> findByRecordsSelective(Iterable<? extends T> entities, Pagination<T> pagination);

    Flux<T> findByRecordsSelective(Publisher<? extends T> entityStream, Pagination<T> pagination);

    Flux<T> findByRecord(T entity, Pagination<T> pagination);

    Flux<T> findByRecord(Publisher<? extends T> entityStream, Pagination<T> pagination);

    Flux<T> findByRecords(Iterable<? extends T> entities, Pagination<T> pagination);

    Flux<T> findByRecords(Publisher<? extends T> entityStream, Pagination<T> pagination);


    //=== 传入 Connection 是为了统一获得事务能力

    Flux<T> findAll(Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecordSelective(T entity, Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecordSelective(Publisher<? extends T> entity, Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecordsSelective(Iterable<? extends T> entities, Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecordsSelective(Publisher<? extends T> entityStream, Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecord(T entity, Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecord(Publisher<? extends T> entity, Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecords(Iterable<? extends T> entities, Pagination<T> pagination, SqlConnection connection);

    Flux<T> findByRecords(Publisher<? extends T> entityStream, Pagination<T> pagination, SqlConnection connection);

}
